<template>
  <app-framework :banner.sync="banners">
    <content-container>
      <div class="title">
        <span>{{ article.title }}</span>
      </div>

      <section class="content" v-html="article.content">
      </section>
    </content-container>
  </app-framework>
</template>

<script>
import AppFramework from '../components/AppFramework'
import ContentContainer from '../components/ContentContainer'
import { getArticle } from '../api/index-api'

export default {
  name: 'Article',
  components: {ContentContainer, AppFramework},
  data() {
    return {
      table: '',
      article: {
        id: 0,
        title: '',
        content: '',
        img: ''
      },
      banners: [
        {
          img: '/images/banner-default.jpg'
        }
      ]
    }
  },
  created() {
    this.article.id = this.$route.query.id
    this.table = this.$route.query.table
    this.getData()
  },
  methods: {
    getData() {
      getArticle(this.table, this.article.id).then((res) => {
        this.article = res.data
        this.banners[0].img = this.article.img
      }).catch(() => {})
    }
  }
}
</script>

<style scoped>
.title{
  line-height: 2;
  position: absolute;
  top:18vw;
  left: 0;
  right: 0;
  z-index: 10000;
  text-align: center;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-size: 50px;
  font-weight: bold;
}

.title span{
  display: inline-block;
  /*background-color: rgba(0,0,0,.3);*/
  background-color: rgba(255,255,255, .9);
  padding: 0 80px;
  border-bottom: 2px solid #fff;
  color: #222;
}

.content{
  font-size: 12px;
  text-indent: 24px;
  line-height: 1.8;
  padding: 20px 0;
}

.content >>> p{
  margin-top:10px;
  font-size: 16px;
}

.content >>> strong{
  font-size: 18px;
  font-weight: bold;
}
</style>
